<?php

/**
 * Clientes form.
 *
 * @package    tercermilenio
 * @subpackage form
 * @author     Your name here
 */
class ClientesForm extends BaseClientesForm {

    public function configure() {
        $cliente = $this->getObject();

    }

    public function setup() {

        parent::setup();

        $choices = array(
            ''  => 'Todos',
            0   => 'Inactivo',
            1   => 'Activo',
        );

        $this->setWidgets(array(
            'cli_id' => new sfWidgetFormInputHidden(),
            'cli_nombre' => new sfWidgetFormInput(),
            'cli_nro_documento' => new sfWidgetFormInput(),
            'cli_provincia' => new sfWidgetFormPropelChoice(array('model' => 'Provincias', 'add_empty' => 'Seleccione una provincia')),
            'cli_localidad' => new sfWidgetFormPropelChoice(array('model' => 'Localidades', 'add_empty' => 'Seleccione una localidad','label' => 'Localidad')),
            'cli_telefono' => new sfWidgetFormInput(),
            'cli_celular' => new sfWidgetFormInput(),
            'cli_credito' => new sfWidgetFormInput(),
            'cli_estado' => new sfWidgetFormChoice(array('choices' => $choices)),
            'cli_fecha_limite'  => new sfWidgetFormDate(),
        ));

        $this->setValidators(array(
            'cli_id' => new sfValidatorPropelChoice(array('model' => 'Clientes', 'column' => 'cli_id', 'required' => false)),
            'cli_nombre' => new sfValidatorString(array('max_length' => 100,'required' => true)),
            'cli_nro_documento' => new sfValidatorInteger(array('required' => true)),
            'cli_provincia' => new sfValidatorPropelChoice(array('model' => 'Provincias', 'column' => 'pcia_id','required' => false)),
            'cli_localidad' => new sfValidatorPropelChoice(array('model' => 'Localidades', 'column' => 'loc_id','required' => true)),
            'cli_telefono' => new sfValidatorString(array('max_length' => 30, 'required' => false)),
            'cli_celular' => new sfValidatorString(array('max_length' => 30, 'required' => false)),
            'cli_credito' => new sfValidatorNumber(array('required' => false)),
            'cli_estado' => new sfValidatorChoice(array('choices' => array('',0,1), 'required' => true)),
            'cli_fecha_limite'  => new sfValidatorDate(array('required' => false)),
        ));

        $this->widgetSchema->setNameFormat('clientes[%s]');

        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
    }

}
